﻿// =====================================================================
//
//  This file is part of the Microsoft Dynamics CRM SDK code samples.
//
//  Copyright (C) Microsoft Corporation.  All rights reserved.
//
//  This source code is intended only as a supplement to Microsoft
//  Development Tools and/or on-line documentation.  See these other
//  materials for detailed information regarding Microsoft code samples.
//
//  THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
//  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
//  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//  PARTICULAR PURPOSE.
//
// =====================================================================
using System.Runtime.Serialization;

namespace Microsoft.Xrm.Sdk.Metadata
{
	[DataContract(Name = "DoubleAttributeMetadata", Namespace = XmlNamespaces.V5.Metadata)]
	public sealed class DoubleAttributeMetadata : AttributeMetadata
	{
		#region Constants
		public const double MinSupportedValue = -1e11;
		public const double MaxSupportedValue = 1e11;
		public const int MinSupportedPrecision = 0;
		public const int MaxSupportedPrecision = 5;
		#endregion

		#region Fields
		private ImeMode? _imeMode;
		private double? _minValue;
		private double? _maxValue;
		private int? _precision;
		#endregion

		#region Constructors
		public DoubleAttributeMetadata()
			: this(null)
		{
		}

		public DoubleAttributeMetadata(string schemaName)
			: base(AttributeTypeCode.Double, schemaName)
		{
		}
		#endregion

		#region Properties
		/// <summary>
		/// Valid for CreateAttribute
		/// Valid for UpdateAttribute
		/// </summary>
		[DataMember]
		public ImeMode? ImeMode
		{
			get { return this._imeMode; }
			set { this._imeMode = value; }
		}

		/// <summary>
		/// Required for CreateAttribute
		/// Valid for UpdateAttribute
		/// </summary>
		[DataMember]
		public double? MaxValue
		{
			get { return this._maxValue; }
			set { this._maxValue = value; }
		}

		/// <summary>
		/// Required for CreateAttribute
		/// Valid for UpdateAttribute
		/// </summary>
		[DataMember]
		public double? MinValue
		{
			get { return this._minValue; }
			set { this._minValue = value; }
		}

		/// <summary>
		/// Required for CreateAttribute
		/// Valid for UpdateAttribute
		/// </summary>
		[DataMember]
		public int? Precision
		{
			get { return this._precision; }
			set { this._precision = value; }
		}
		#endregion
	}
}
